package com.good.webapi.Util;

import com.good.webapi.Models.Audience;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.Timestamp;

public class SignClass {
    @Autowired
    static
    Audience audience;
    public static boolean check(long timestamp,String sign,String keys){
        long  nowtimestamp=  System.currentTimeMillis();
        if(nowtimestamp-timestamp>3000)
        {
            return  false;
        }else
        {
            String str=timestamp+keys+audience.getSecretKey();
            str= DigestUtils.md5DigestAsHex(str.getBytes());
            return str.equals(sign);
        }

    }
}
